package org.lds.hotkey.console.business.appinstance.converter;

import org.lds.hotkey.console.business.appinstance.entity.AppInstance;
import org.lds.hotkey.console.business.appinstance.model.request.AppInstanceBaseCreateRequest;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class AppInstanceBaseCreateRequestToEntityConverter implements Converter<AppInstanceBaseCreateRequest, AppInstance> {

    @Override
    public AppInstance convert(AppInstanceBaseCreateRequest source) {
        LocalDateTime date = LocalDateTime.now();
        return AppInstance.builder()
                .appId(source.getAppId())
                .ip(source.getIp())
                .port(source.getPort())
                .creator(source.getCreator())
                .modifier(source.getModifier())
                .createTime(date)
                .updateTime(date)
                .build();
    }

}


